package com.ocom.webapi.controller;

import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.webapi.ComIdVo;
import com.ocom.common.vo.webapi.StringKeyVo;
import com.ocom.redis.util.RedisUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: TODO
 * @Author: 朱晖
 * @Date: 2022/8/16
 **/
@RestController
public class ImportErrController {

	@Resource
	RedisUtil redisUtil;

	@PostMapping(WebApiServiceUrl.URL_importFail)
	public Result  getErrList(@RequestBody ComIdVo comIdVo){

		Map<String,Object>  map =new HashMap<>();
		map.put("total",0);
		map.put("list",redisUtil.lGet("ImportErr:"+comIdVo.getComId(),0l,-1l));

		return ResultUtil.success(map);
	}



	@PostMapping(WebApiServiceUrl.URL_importFailDetail)
	public Result  getErrDetail(@RequestBody StringKeyVo stringKeyVo){
		Map<String,Object>  map =new HashMap<>();
		map.put("page",stringKeyVo.getPage());
		map.put("size",100);
		map.put("total",redisUtil.listSize(stringKeyVo.getKey()));
//		map.put("list",redisUtil.lGet(stringKeyVo.getKey(),0l,-1l));
		map.put("list",redisUtil.lGet(stringKeyVo.getKey(),(stringKeyVo.getPage()-1)*100l,stringKeyVo.getPage()*100l));
		return ResultUtil.success(map);
	}
}
